<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport"
          content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">

    <title>{$shmc}-快速付款</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/Css/pay.css?id=11"/>


    <script language="javascript">
        function yuezf() {

            var ordid = $('#orderid').val();
            var pirce = $('#wrap input[name="price"]:checked ').val();
            var msg = "确认支付？\n\n";
            if (confirm(msg) == true) {


                if (price < 0.01) {
                    alert('金额不能小于0.01元');
                    $('#price').focus();
                } else {
                    $("#submit2").removeClass("submit");
                    $("#submit2").addClass("submita");
                    $('#submit2').attr('onclick', '()');
                    $('#submit2').val('正在处理中...');
                    $.ajax({
                        type: "POST",
                        url: "__CONTROLLER__/yuepay/id/{$id}",

                        cache: false,
                        dataType: "json",
                        data: $('#tab').serialize(),

                        success: function (data) {
                            if (data === 0) {

                                alert('支付成功');
                                window.location.replace("__CONTROLLER__/orderinfo/id/{$id}/orderid/" + ordid);
                            } else {

                                alert('支付失败');
                            }

                        }
                    });

                }
            } else {
                return false;
            }
        }

        function zf() {

            var pirce = $('#wrap input[name="price"]:checked ').val();
            if (price < 0.01) {
                alert('金额不能小于0.01元');
                $('#price').focus();
            } else {
                $("#submit").removeClass("submit");
                $("#submit").addClass("submita");
                $('#submit').attr('onclick', '()');
                $('#submit').val('正在处理中...');
                $.ajax({
                    type: "POST",
                    url: "__CONTROLLER__/pay2/id/{$id}",

                    cache: false,
                    dataType: "json",
                    data: $('#tab').serialize(),

                    success: function (data) {
                        if (typeof WeixinJSBridge == "undefined"){
                            if( document.addEventListener ){
                                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                            }else if (document.attachEvent){
                                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                            }
                        }else{
                            onBridgeReady(data);
                        }


                    }
                });

            }
        }

        function onBridgeReady(data) {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                data,
                function (res) {
                    WeixinJSBridge.log(res.err_msg);
                    if (res.err_msg === 'get_brand_wcpay_request:ok') {

                        paysuccess();

                    } else {

                        $("#submit").removeClass("submita");
                        $("#submit").addClass("submit");
                        $('#submit').attr('onclick', 'zf()');
                        $('#submit').val('重新支付');

                    }

                });
        }

        function paysuccess() {
            var ordid = $('#orderid').val();
            $.ajax({
                type: "POST",
                url: "__CONTROLLER__/payover/id/{$id}/orderid/" + ordid,

                cache: false,
                dataType: "json",
                data: {},

                success: function (data) {
                    if (data === 0) {

                        window.location.replace("__CONTROLLER__/orderinfo/id/{$id}/orderid/" + ordid);
                    } else {

                        alert('支付失败');
                    }
                    ////
                }


            });

        }
    </script>
</head>
<body>

<div class="zt">
    <div class="zw"></div>
    <div style="width: 100%;text-align: center">
        <br/>
        <div>在线收款</div>
    </div>
    <div class="zw"></div>
    <div class="cardexplain">

        <ul class="round">

            <li class="nob">
                <table>

                    <tr>
                        <td>
                            <form role="form" id="tab">
                                <span><font color="blue">出发地：</font>{$order['start']}</span>
                                <span><font color="blue">目的地：</font>{$order['end']}</span>
                                <span><font color="blue">预约时间：</font>{$order['starttime']}</span>
                                <span><font color="blue">订单类型：</font>{$order['fs']}</span>
                                <if condition="$order['fs'] neq '代运订单'">
                                    <span><font color="blue">成人：</font>{$order['num']}人;<font color="blue">儿童：</font>{$order['child']}人</span>
                                    <elseif condition="$order['fs'] eq '代运订单'"/>
                                    <span><font color="blue">收货人：</font>{$order['xingming']};<font
                                            color="blue">电话：</font>{$order['dianhua']}</span>
                                </if>
                                <span><font color="red">联系方式：</font>{$lx['name']}<a
                                        href="tel:{$order['dianhua']}">{$order.dianhua}</a></span>
                                <span><font color="red">价  格：</font>￥{$order['price']}</span>
                                <span><font color="blue">备  注：</font>{$order['crc']}</span>
                                <span><font color="blue">航  班：</font>{$order['hangban']}</span>
                                <input type="hidden" name="price" value="{$order['price']}" id="price"/>

                                <input type="hidden" name="openid" id="openid" value="{$openid}"/>
                                <input type="hidden" name="orderid" id="orderid" value="{$order['orderid']}"/>

                            </form>

                        <td>
                    </tr>
                </table>


        </ul>
    </div>


    <div id="payDom" class="cardexplain">
        <div class="footReturn" style="text-align:center">
            <input type="button" onclick="zf()" class="submit" id="submit" value="微信支付"/>

            <if condition="$yue  egt $price">
                <input type="button" onclick="yuezf()" class="submit" id="submit2" value="余额支付"/>
            </if>

        </div>
    </div>
    <div class="foots"><span>支付完成后，如需退款请及时联系店员</span></div>
    <div class="footer">

        <span></span>
    </div>
    <div style="clean:both"></div>
</div>
</body>
</html>